package com.example.demo.base.thread;

/**
 * @program: demo
 * @description: 每个线程睡眠时间
 * @author: zhouhongtao
 * @happyCreateTime: 2021/10/27 10:17
 */
public class SleepDemo {


    public static void main(String[] args){
        long startTime1 = System.currentTimeMillis();

        sleep(3000);

        new Thread(()->{

            long startTime = System.currentTimeMillis();

            sleep(2000);

            long timeEnd = System.currentTimeMillis();

            System.out.println("spend time 毫秒: " + (timeEnd - startTime));


        }).start();



        long timeEnd = System.currentTimeMillis();

        System.out.println("Main spend time 毫秒: " + (timeEnd - startTime1));


    }

    private static void sleep(int time){
        try {
            Thread.sleep(time);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }


}
